Skip to main content

WACI DIDComm

Message Types

The protocol defines different message flows depending on whether the intention is to issue a credential or to present a credential. These messages are categorized into steps according to the specification. WACI-DIDComm Interop Profile.

StepIssuancePresentation
1Out of bandOut of band
2Propose CredentialPropose Presentation
3Offer Credential Request Presentation
4Request CredentialPresent Proof
5AckAck Presentation

The WACIInterpreter service is responsible for taking the message, determining if it is of the WACI type, and identifying which specific flow it belongs to. It then responds with the appropriate message for that flow.

1. Install

npm i @extrimian/waci

2. Instance

const waci = new WACIInterpreter();

3. Interpret the message

waci.isWACIMessage(messageToCheck);

messageToCheck could be any type of message, if is not a WACI type it dismiss it.

To be a WACI type should have the following structure:

type WACIMessage = {
type: WACIMessageType;
id: string;
from: string;
to?: string[];
body?: any;
pthid?: string;
thid?: string;
attachments?: any[];
};

4. Process the message

waci.processMessage(WACIMessage[])

The processMessage function is responsible for receiving a WACI message and delegating its interpretation to the appropriate handler based on the message type.

5. Set Up For

The WACIInterpreter has a method called setUpFor to define the flow corresponding to the credential exchange.

new WACIInterpreter().setUpFor<Actor>(params: InputCallbacks[Actor], actor: Actor);

It requires the definition of the Actor since the WACI flow changes depending on the actors involved.

enum Actor {
Holder = "holder",
Issuer = "issuer",
Verifier = "verifier",
}

Then, different types of callbacks need to be configured based on whether you want to issue, present, or verify a credential.

For example, for credential verification, it should be instantiated as follows:

 waci.setUpFor(
{
getPresentationDefinition: (): any => {
return [credentialModel];
},
verifyCredential: async (credential: any): Promise<boolean> => {
console.log('Credential', JSON.stringify(credential, null, 2));

const vcVerifierService = new VCVerifierService({
didDocumentResolver: didResolver.resolveDid,
});

const verifier = await vcVerifierService.verify(credential, {
name: 'assertionMethod',
});

console.log('verifiers', JSON.stringify(verifier, null, 2));

return verifier.result;
},
}
Actor.Verifier)